/*
 * ﻿Copyright (C) 2013 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.newmainsoftech.eatestutil.ejbtestutil;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.persistence.EntityManager;

/**
 * Contract to provide access means to <code>EntityManager</code> and its features.<br />
 * The implementation class must have either <code>&#x40;Stateless</code> or <code>&#x40;Statefull</code> 
 * annotation in order to appropriately provide access means to <code>EntityManager</code> in EJB 
 * container managed way.
 * 
 * @author Arata Y.
 */
public interface EntityManagerFacade extends EntityManager {
	EntityManager getEntityManager();
	/**
	 * To run external object's method under EJB context.<br /> 
	 * 
	 * @param externalObj : Owner of method being provided with <code>externalMethod</code> argument.
	 * @param externalMethod : Method to be executed.
	 * @param args : Arguments to method being provided with <code>externalMethod</code> argument.
	 * @return Result object of execution of method (being provided with <code>externalMethod</code> 
	 * argument) on method owner object (being provided with <code>externalObj</code> argument).
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	Object runExternalMethod( Object externalObj, Method externalMethod, Object... args) 
	throws IllegalAccessException, InvocationTargetException;
}
